﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class downloadDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string sql = "select * from Download_Type";
        rptDownload.DataSource = DataAccess.GetDataTable(sql, null);
        rptDownload.DataBind();
        if (!IsPostBack)
        {
            lbDownloadUrl.Visible = true;
            if (Request.QueryString["dowID"] != null && Request.QueryString["dowID"] != "")
            {
                bindInfo(Request.QueryString["dowID"]);
                updateHits(Request.QueryString["dowID"]);
                lbDownloadUrl.CommandName = Request.QueryString["dowID"];

            }
        }
    }
    /// <summary>
    /// 孙旭峰
    /// </summary>
    /// 2011.4.8修改显示-朱胜贤
    /// <param name="dowID"></param>
    public void bindInfo(string dowID)
    {
        string sql = "select * from Download_Info where dowID=" + dowID;
        DataTable dt = DataAccess.GetDataTable(sql, null);
        lblTitleTop.Text = "<a href=Download.aspx?dowType=" + dt.Rows[0]["dowType"].ToString() + ">" + dt.Rows[0]["dowType"].ToString() + "</a>&nbsp> " + dt.Rows[0]["dowTitle"].ToString();
        lblTitle.Text = dt.Rows[0]["dowTitle"].ToString();
        //lblType.Text = dt.Rows[0]["dowHot"].ToString() == "true" ? "推荐" : "" + dt.Rows[0]["dowOntop"].ToString() == "true" ? "置顶" : "";
        lblInfo.Text = "更新时间：<span class=\"info_t\">" + dt.Rows[0]["dowUpdateTime"].ToString() + "</span>　点击次数：<span class=\"info_t\">" + dt.Rows[0]["dowHits"].ToString() + "</span>　下载次数：<span class=\"info_t\">" + dt.Rows[0]["dowLoad"].ToString() + "</span>";
        //lblContent.Text = dt.Rows[0]["dowdescribe"].ToString() + "<br>下载地址：<a href=" + dt.Rows[0]["dowUrl"].ToString().Substring(2)+">点击下载</a>";
        //lbDownloadUrl.PostBackUrl = dt.Rows[0]["dowUrl"].ToString();
    }
    protected void updateHits(string dowID)
    {
        string sql1 = "update Download_Info set dowHits=dowHits+1 where dowID=" + dowID;
        DataAccess.ExecuteSQL(sql1, null);
    }
    protected void lbDownloadUrl_Click(object sender, EventArgs e)
    {
        string sql1 = "update Download_Info set dowLoad=dowLoad+1 where dowID=" + lbDownloadUrl.CommandName.ToString();
        DataAccess.ExecuteSQL(sql1, null);
        string sql2 = "select * from Download_Info where dowID=" + lbDownloadUrl.CommandName.ToString();
        DataTable dt1 = DataAccess.GetDataTable(sql2, null);
        Response.Redirect(dt1.Rows[0]["dowUrl"].ToString().Substring(2));
    }
}